﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using NineSeas.Models;
using Orchard;
using Orchard.Localization;
using Orchard.WebApi;
using Orchard.ContentManagement;
using NineSeas.ViewModels;
using Orchard.Users.Models;
namespace NineSeas.Api
{
    public class AuthorsController: ApiController
    {
        private IOrchardServices _services;
        private Localizer T { get; set; }
        public AuthorsController(IOrchardServices service)
        {
            this._services = service;
            T = NullLocalizer.Instance;
        }

        public AuthorProfileViewModel Get(int id)
        {
            AuthorProfilePart profile = _services.ContentManager.Get<AuthorProfilePart>(id);

            var viewModel = new AuthorProfileViewModel() { 
                DisplayName = profile.DisplayName,
                DateOfBirth = profile.DateOfBirth,
                BannerColor = profile.BannerColor,
                AvatarUrl = profile.AvatarUrl,
                AvatarStoragePath = profile.AvatarStoragePath,
                Email = profile.As<UserPart>().Email,
                Phone = profile.Phone,
                StatusMessage = profile.StatusMessage
            };

            return viewModel;
        }
    }
}